import { City } from '../../City';
import { Zone } from './Zone';
import { Resident } from '../modules/Resident';
import { Building } from '../Building';

/** 
 * 居民区 
 */
export class ResidentialZone extends Zone {

    resident = new Resident(this);

    constructor() {
        super();
        this.name = generateBuildingName();
        this.type = Building.type.residential;
    }

    simulate(city: City) {
        super.simulate(city);
        this.resident.simulate(city);
    }

    dispose() {
        this.resident.dispose();
        super.dispose();
    }

    toHTML() {
        let html = super.toHTML();
        html += this.resident.toHTML();
        return html;
    }
}

// Arrays of different name components
const prefixes = ['春晓花园', '明月江南', '晓风绿岸', '名门世家', '状元村', '明月湾', '江南晓庄', '帝豪国际', '潮悦'];
const suffixes = ['一号', '二号', '三号', '四号', '五号', '六号', '七号', '八号', '九号', '十号'];

// Function to generate a random building name
function generateBuildingName() {
    const prefix = prefixes[Math.floor(Math.random() * prefixes.length)];
    const suffix = suffixes[Math.floor(Math.random() * suffixes.length)];

    return prefix + ' ' + suffix;
}